﻿//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Web;
//using System.Drawing;
//using System.Text.RegularExpressions;


//namespace SellerProject
//{
//    public class RegexEditor
//    {
//        /** RegexTextBox继承自TextBox控件
//        * 能够通过正则表达式对数据进行有效性校验 */  
//        public class RegexTextBox : System.Web.UI.WebControls.TextBox
//        {
//            private string strRegex;//用于校验的正则表达式
//            private string strVerifyError;//校验错误的提示
//            private bool bIsVerifySuccess;//是否检验成功
//            private bool bIsDisplayError;//是否显示错误
//            private bool bToVerify;//是否进行校验

//            //属性：用于校验的正则表达式
//            public string RegexString{get{return strRegex;}set{strRegex = value;}}
//            //属性：检验错误的提示
//            public string VerifyErrorString            {            get            {            return strVerifyError;            }           set            {            strVerifyError = value;            }           }

//            //属性：是否检验成功
//            public bool IsVerifySuccess
//            {get{return bIsVerifySuccess;}
//            set{bIsVerifySuccess = value;}}

//            //属性：是否显示校验错误
//            public bool IsDisplayError{get{return bIsDisplayError;}set{bIsDisplayError = value;}}

//            public bool ToVerify{get{return bToVerify;}set{bToVerify = value;}}

//            //构造函数
//            public RegexTextBox(){InitializeComponent();}



//            //初始化变量以及控件属性
//            void InitializeComponent() 
//            {
//                RegexString = "";
//                VerifyErrorString = "";
//                IsVerifySuccess = true;
//                IsDisplayError = false;
//                ToVerify = false;
//                this.ID = "RegexTextBox";
//                //this += new System.ComponentModel.CancelEventHandler(this.OnValidatingData); 
//                //Validating
//            }



////私有过程：校验数据

//private bool VerifyData()

//{

//IsVerifySuccess = Regex.IsMatch(this.Text,RegexString);

//return IsVerifySuccess;

//}



////事件处理函数：校验数据

//private void OnValidatingData(object sender, System.ComponentModel.CancelEventArgs e)

//{

//if(!ToVerify)//不需要校验直接退出

//{

//e.Cancel = false;

//return;

//}

//if(!VerifyData())//校验不正确..

//{

//if(this.IsDisplayError)//要求显示校验错误提示..

//{

//MessageBox.Show(VerifyErrorString,"警告：");

//}

//else//要求不显示校验错误提示..

//{

//this.SelectAll();

//}//end if

//e.Cancel = true;

//}

//else//校验正确..

//{

//e.Cancel = false;

//}//end if

//}

//}//End Class

//}//End NameSpace
//    }
//}